function search(nums: number[], target: number): number {
    let low: number = 0, high: number = nums.length - 1
    while (low <= high) {
        const mid: number = Math.floor((high - low) / 2) + low
        const num: number = nums[mid]
        if (num === target) {
            return mid
        } else if (num > target) {
            high = mid - 1
        } else {
            low = mid + 1
        }
    }
    return -1
}